package com.hbnu.tonghengchang;

import java.util.Scanner;

public class BankAccount {
    Scanner sc = new Scanner(System.in);
    private String accountNumber;
    private double balance;

    public BankAccount() {
    }

    public BankAccount(String accountNumber, double balance) {
        this.accountNumber = accountNumber;
        this.balance = balance;
    }

    @Override
    public String toString() {
        return "BankAccount{" +
                "accountNumber='" + accountNumber + '\'' +
                ", balance=" + balance +
                '}';
    }

    /**
     * 存款方法
     */
    public void deposit(double num) {
        balance = num;
    }

    /**
     * 取款方法
     */
    public void withdraw() {
        System.out.println("请输入您要取出的金额：");
        double num = sc.nextInt();
        double stock = getBalance();
        if (stock < num) System.out.println("您的余额不足！！");
        else deposit(stock - num);
    }

    /**
     * 查看余额方法
     */
    public double getBalance() {
        return balance;
    }

    /**
     * SavingsAccount子类
     */
    public class SavingsAccount {
        private double interestRate = 0.002;
        private double interest;
        public void calculateInterest() {//计算利息
            interest = getBalance()*interestRate;
        }

    }
}
